//---------------------------------------------------------------------------
#ifndef uDessinH
#define uDessinH
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <math.h>
#include "uEtat.h"
#define RECTIF_DEFAUT 1

#define IsValidCanvas( c)   (!::IsBadReadPtr( c, sizeof( TCanvas)))


extern TCoordonnee ETATAPI __fastcall Aspect( float Width, bool bX);
#define AspectX( Width)            Aspect( Width, true)
#define AspectY( Width)            Aspect( Width, false)






typedef struct{
    bool        Visible;
    TCoordonnee LargeurSaisie;
    TCoordonnee GaucheCalc;
    TCoordonnee LargeurCalc;
    TCoordonnee LargeurMin;
    TCoordonnee LargeurMax;
    int         nOrdreAffichage;
    bool        PremCol;
}COLONNE;
void ETATAPI __fastcall CalcCoorColonne( const TCoorRect &RcArround, TList *LstColonnes, float LargeurTrait);
typedef struct{
    TCoordonnee HautCalc;
    TCoordonnee BasCalc;
}LIGNE;
void ETATAPI __fastcall CalcCoorLigne( const TCoorRect &RcArround, TList *LstLignes, float LargeurTrait);
                                        /*TCoordonnee __fastcall GetGaucheColonne( const TCoorRect &RcArround, TList *LstColonnes, int nCol, float LargeurTrait);
TCoordonnee __fastcall GetLargeurColonne( const TCoorRect &RcArround, TList *LstColonnes, int nCol, float LargeurTrait);*/
void ETATAPI __fastcall DrawTableau( TObject *Object, const TCoorRect &Rc, int RayonCourbure,
                                     TColor  BrushColor, TBrushStyle BrushStyle,
                                     TColor  PenColor,   TPenStyle   PenStyle,
                                     float PenWidthGauche, float PenWidthHaut,
                                     float PenWidthDroit, float PenWidthBas,
                                     TList *LstColonnes, float PenWidthColonnes, TList *LstLignes);

void ETATAPI __fastcall DrawLine( TObject *Object, const TPoint &Orig, const TPoint &Dest,
                                  TColor  PenColor,   TPenStyle   PenStyle,
                                  float PenWidth, int Sens);

void ETATAPI __fastcall DrawRectangle( TObject *Object, const TRect &Rc, int RayonCourbure,
                               TColor  BrushColor, TBrushStyle BrushStyle,
                               TColor  PenColor,   TPenStyle   PenStyle,
                               float PenWidthGauche, float PenWidthHaut,
                               float PenWidthDroit, float PenWidthBas,
                               bool bMoitieGauche=false, bool bMoitieDroit=false);
void ETATAPI __fastcall DrawEllipse( TObject *Object, const TRect &Rc,
                             TColor  BrushColor, TBrushStyle BrushStyle,
                             TColor  PenColor,   TPenStyle   PenStyle, float PenWidth);

enum Bool_Format { bf_CaseACocher, bf_ON, bf_OuiNon, bf_VF, bf_VraiFaux, bf_Croix, bf_Max = bf_Croix};

void CalculSizeSupport(TCanvas *canvas, int nResolRef, const char *s, int *&lpDx, SIZE &PrinterSize);
AnsiString ETATAPI __fastcall FormateTexte( Text_Presentation Presentation, const AnsiString &t, Text_Format Format, const void* pvFormat);
bool __fastcall CreationBitmapIntermediaire( TRect &Rc, const TRect &_Rc, TCanvas *canvas, Graphics::TBitmap *&Bmp, TColor FontColor, bool FixeResol = false);

void ETATAPI __fastcall DrawTexte( TObject *Object, const TRect &_Rc, const TCoordonnee &LargeurCpEcran, const TCoordonnee &HauteurCpEcran, const EICFont *font, const AnsiString& Texte, Text_Presentation Presentation,
                                   int Orientation=0, Text_Format Format = tf_Normal, const void* vFormat = NULL, bool SoulignePointille = false, int EspaceLigne = 0);
    //retourne le dernier caractère imprimé
HANDLE __fastcall CreateAndInitRichEdit( HANDLE hPapa, const TCoorRect &Rc, const EICFont *Font, const AnsiString& Texte, Text_Presentation Presentation, int FirstCharPrint);
void ETATAPI __fastcall DrawRichText( TObject *Object, const TCoorRect &_Rc, const EICFont *font,
                                      const AnsiString& Texte, Text_Presentation Presentation,
                                      TColor BrushColor, TBrushStyle BrushStyle,
                                      long nCharDebut, long &nCharFin);

enum Type_Etirement {
    Et_Normal      = 0x00000000,
    Et_Centre      = 0x00000001,
    Et_Etire       = 0x00000002,
    Et_Homo        = 0x00000003,
    Et_Homo_Centre = 0x00000004
};
void ETATAPI __fastcall DrawImage( TObject *Object, const TCoorRect &Rc,  const AnsiString& File, TPicture *Picture, Type_Etirement Etirement, const TCoorPoint *ptOrigine = NULL, bool bTransparent = false);

void ETATAPI __fastcall DrawFleche( TObject *Object,   const TRect &Rc,
                            TColor PenColor,   TPenStyle   PenStyle, float PenWidth,
                            TColor BrushColor, TBrushStyle BrushStyle,
                            int Epaisseur,  int nLargeurPointe, int nHauteurPointe, int Orientation);


int __fastcall CompteEspaces( const AnsiString &s);

int __fastcall AjustFontSize( const char *sz, int nNbEspaces, TCanvas *Canvas, const SIZE &SizePrinter,
                               int nResolRef, int nResolOut, int SizeEcranX, bool bForce, LPINT &lpDx);


void ETATAPI __fastcall DessineFiligrane( TObject *Support, const TCoordonnee &Largeur, const TCoordonnee &Hauteur, const TCoorRect &Marges, const AnsiString& Texte);
//---------------------------------------------------------------------------


 #endif
